#ifndef CRENDERENEMY_H
#define CRENDERENEMY_H

#include "../include/IRenderEntity.h"

class CDefaultPowerUpBehaviour;
class CDefaultEnemyBehaviour;
class CRenderPlayer;

//**************************
//Manage rendering of a player
//**************************
class CRenderEnemy : public IRenderEntity
{
    private:
        CDefaultEnemyBehaviour * m_EnemyEntity;	//Enemy to render
        CDefaultPowerUpBehaviour * m_PowerUpEntity;   //PowerUp bind to the enemy when it dies.
        bool m_bHasPowerUp;      //true if the enemy has a power up, put to false if it's caught or if there isn't power up

        int m_iInitX;           //initial value on the abscissa
        int m_iInitY;           //initial value on the ordinary

        long m_lAppearance;     //time before the enemy have to appear in the level
        long m_lBeginBlink;     //beginning of the blinking


    public:
        //**************************
        //Description : Constructor
        //Parameters : None
        //Note : None
        //**************************
        CRenderEnemy();

        //**************************
        //Description : Constructor
        //Parameters : The screen,
        //             A pointer toward the enemy entity
        //             Animations for enemy and its shots
        //             its time before appearance
        //Note : None
        //**************************
        CRenderEnemy(SDL_Surface * _screen,
                        CDefaultEnemyBehaviour * _Enemy, long _lAppearance,
                        CSpriteAnimation * _EnemyAnimations,
                        CSpriteAnimation * _EnemyShotsAnimation,
                        CDefaultPowerUpBehaviour * _PowerUp = NULL,
                        CSpriteAnimation * _PowerUpAnimation = NULL);

        //**************************
        //Description : Copy Constructor
        //Parameters : A CRenderEnemy
        //Note : None
        //**************************
        CRenderEnemy(CRenderEnemy & _RenderEnemy);

        //**************************
        //Description : Destructor
        //Parameters : None
        //Note : None
        //**************************
        virtual ~CRenderEnemy();

        //**************************
        //Description : Set the initial value for the rendering
        //Parameters : The screen,
        //             A pointer toward the enemy entity
        //             Animations for enemy and its shots
        //             its time before appearance
        //             The PowerUp Behaviour (if any) and the animation for the power up (if any)
        //Return Value : None
        //Note : None
        //**************************
        void SetRender(SDL_Surface * _screen,
                        CDefaultEnemyBehaviour * _Enemy, long _lAppearance,
                        CSpriteAnimation * _EnemyAnimations,
                        CSpriteAnimation * _EnemyShotsAnimation,
                        CDefaultPowerUpBehaviour * _PowerUp = NULL,
                        CSpriteAnimation * _PowerUpAnimation = NULL);

        //**************************
        //Description : Initialise the rendering to its beginning
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void InitRender();

        //**************************
        //Description : Return the time before the appearance of the enemy
        //Parameters : None
        //Return Value : The time of appearance
        //Note : None
        //**************************
        long GetAppearance() const;

        //**************************
        //Description : Set sprites for the rendering if it's not done
        //Parameters : animations for the enemy
        //              animations for its shots
        //Return Value : None
        //Note : None
        //**************************
        void SetSprites(CSpriteAnimation * _EnemyAnimations,
                        CSpriteAnimation * _EnemyShotsAnimation);

        //**************************
        //Description : Return the Enemy entity
        //Parameters : None
        //Return Value : The Enemy entity
        //Note : None
        //**************************
        CDefaultEnemyBehaviour * GetEnemyBehaviour() const;

        //**************************
        //Description : Set m_EnemyEntity if it's not done
        //Parameters : The Enemy Behaviour and its time before appearance
        //Return Value : None
        //Note : None
        //**************************
        void SetEnemyBehaviour(CDefaultEnemyBehaviour * _Enemy, long _lAppearance);

        //**************************
        //Description : Return the PowerUp entity
        //Parameters : None
        //Return Value : The PowerUp entity
        //Note : None
        //**************************
        CDefaultPowerUpBehaviour * GetPowerUpBehaviour() const;

        //**************************
        //Description : Set m_PowerUpEntity if it's not done
        //Parameters : The PowerUp Behaviour and the animation for the power up
        //Return Value : None
        //Note : None
        //**************************
        void SetPowerUpBehaviour(CDefaultPowerUpBehaviour * _PowerUp, CSpriteAnimation * _PowerUpAnimation);

        //**************************
        //Description : Return the value of m_bHasPowerUp in order to know if the enemy has a power up or not
        //Parameters : None
        //Return Value : true if the enemy has a power up active, otherwise false
        //Note : None
        //**************************
        bool HasPowerUpBehaviour() const;

        //**************************
        //Description : The player caught the power up, so the power up is now NULL
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void LosePowerUpBehaviour();

        //**************************
        //Description : Render the Shot
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void RenderShots();

        //**************************
        //Description : Render the Entity
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void RenderEntity();

        //**************************
        //Description : Render the entity and all things that have connections with it (shots of an entity, power up after death of an enemy, ...)
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void Render();

        //**************************
        //Description : Test if the player collide with the ennemy and/or its shots
        //Parameters : The player
        //Return Value : True if there is collision, false if not
        //Note : None
        //**************************
        bool CollideWithPlayer(CRenderPlayer * _Player);

        //**************************
        //Description : Test if the enemy is dead
        //Parameters : None
        //Return Value : True if the enemy is considered as dead, otherwise false
        //Note : The enemy is considered has dead when its animation of death has finished and
        //      When its powerup (if it has any) is caught or out of the screen
        //**************************
        bool IsEnemyDead() const;
};

#endif

